﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IPC.Communication.BasicFramework;

namespace IPC.Communication.Core.IMessage
{
    public class HslMessage : INetMessage
    {
        public int ProtocolHeadBytesLength
        {
            get
            {
                return 32;
            }
        }

        public byte[] HeadBytes
        {
            get;
            set;
        }

        public byte[] ContentBytes
        {
            get;
            set;
        }

        public byte[] SendBytes
        {
            get;
            set;
        }

        public bool CheckHeadBytesLegal(byte[] token)
        {
            bool flag = this.HeadBytes == null;
            bool result;
            if (flag)
            {
                result = false;
            }
            else
            {
                byte[] expr_18 = this.HeadBytes;
                bool flag2 = expr_18 != null && expr_18.Length >= 32;
                result = (flag2 && SoftBasic.IsTwoBytesEquel(this.HeadBytes, 12, token, 0, 16));
            }
            return result;
        }

        public int GetContentLengthByHeadBytes()
        {
            byte[] expr_07 = this.HeadBytes;
            bool flag = expr_07 != null && expr_07.Length >= 32;
            int result;
            if (flag)
            {
                result = BitConverter.ToInt32(this.HeadBytes, 28);
            }
            else
            {
                result = 0;
            }
            return result;
        }

        public int GetHeadBytesIdentity()
        {
            byte[] expr_07 = this.HeadBytes;
            bool flag = expr_07 != null && expr_07.Length >= 32;
            int result;
            if (flag)
            {
                result = BitConverter.ToInt32(this.HeadBytes, 4);
            }
            else
            {
                result = 0;
            }
            return result;
        }
    }
}
